﻿using CUREBusinessLogicLayer.Harmful;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CURE.Collect
{
    public partial class LedgerInfo : System.Web.UI.Page
    {
        #region 变量
        public string id; public string Id { get { return id; } set { id = value; } }//流水号（主键）
        public string fid; public string FID { get { return fid; } set { fid = value; } }//F卡号
        public string deviceNo; public string DeviceNo { get { return deviceNo; } set { deviceNo = value; } }//设备编号
        public string spec; public string Spec { get { return spec; } set { spec = value; } }//规格
        public string proMonth; public string ProMonth { get { return proMonth; } set { proMonth = value; } }//生产月份

        public string proDay; public string ProDay { get { return proDay; } set { proDay = value; } }//生产日期
        public string orderBatch; public string OrderBatch { get { return orderBatch; } set { orderBatch = value; } }//指令批次号
        public string trayNo; public string TrayNo { get { return trayNo; } set { trayNo = value; } }//橡胶托盘编号
        public string trayBatch; public string TrayBatch { get { return trayBatch; } set { trayBatch = value; } }//橡胶批次
        public string expireMonth; public string ExpireMonth { get { return expireMonth; } set { expireMonth = value; } }//过期的月份

        public string expireDay; public string ExpireDay { get { return expireDay; } set { expireDay = value; } }//过期天数
        public string proTime; public string ProTime { get { return proTime; } set { proTime = value; } }//生产时间
        public string weight; public string Weight { get { return weight; } set { weight = value; } }//重量 
        public string reason; public string Reason { get { return reason; } set { reason = value; } }//原因
        public string fClass; public string FClass { get { return fClass; } set { fClass = value; } }//班别

        public string machine; public string Machine { get { return machine; } set { machine = value; } }//机台
        public string material; public string Material { get { return material; } set { material = value; } }//部材名称
        public string filmModel; public string FilmModel { get { return filmModel; } set { filmModel = value; } }//胶片型号
        public string oilModel; public string OilModel { get { return oilModel; } set { oilModel = value; } }//油型号
        public string actualNum; public string ActualNum { get { return actualNum; } set { actualNum = value; } }//实际保留数量

        public string bTNo; public string BTNo { get { return bTNo; } set { bTNo = value; } }//实际保留BT数
        public string bJBTNO; public string BJBTNO { get { return bJBTNO; } set { bJBTNO = value; } }//lot report报警BT数
        public string okMan; public string OkMan { get { return okMan; } set { okMan = value; } }//确认者
        public string field; public string Field { get { return field; } set { field = value; } }//保留置场
        public string makeMan; public string MakeMan { get { return makeMan; } set { makeMan = value; } }//制造确认者

        public string skiller; public string Skiller { get { return skiller; } set { skiller = value; } }//技术确认者
        public string handlerTime; public string HandlerTime { get { return handlerTime; } set { handlerTime = value; } }//处理日期
        public string fClass2; public string FClass2 { get { return fClass2; } set { fClass2 = value; } }//班别/直
        public string machine2; public string Machine2 { get { return machine2; } set { machine2 = value; } }//处理机台
        public string subModel; public string SubModel { get { return subModel; } set { subModel = value; } }//混入主体型号

        public string subBTNum; public string SubBTNum { get { return subBTNum; } set { subBTNum = value; } }//混入主体BT数
        public string interfuse; public string Interfuse { get { return interfuse; } set { interfuse = value; } }//混入量
        public string residual; public string Residual { get { return residual; } set { residual = value; } }//有无残留
        public string remarks; public string Remarks { get { return remarks; } set { remarks = value; } }//备注

        #endregion

        LedgerBll leBll = new LedgerBll();

        protected void Page_Load(object sender, EventArgs e)
        {

            id = Request.QueryString["FInterID"];


            DataTable dt = GetLedgerById();
            if (dt.Rows.Count > 0 && dt != null)
            {
                id = ColumnChange(dt, "ID");
                fid = ColumnChange(dt, "FID");
                deviceNo = ColumnChange(dt, "DeviceNo");
                spec = ColumnChange(dt, "Spec");
                proMonth = ColumnChange(dt, "ProMonth");
                proDay = ColumnChange(dt, "ProDay");
                orderBatch = ColumnChange(dt, "OrderBatch");
                trayNo = ColumnChange(dt, "TrayNo");
                trayBatch = ColumnChange(dt, "TrayBatch");
                expireMonth = ColumnChange(dt, "ExpireMonth");
                expireDay = ColumnChange(dt, "ExpireDay");
                proTime = ColumnChange(dt, "ProTime");
                weight = ColumnChange(dt, "Weight");
                reason = ColumnChange(dt, "Reason");
                fClass = ColumnChange(dt, "FClass");
                machine = ColumnChange(dt, "Machine");
                material = ColumnChange(dt, "Material");
                filmModel = ColumnChange(dt, "FilmModel");
                oilModel = ColumnChange(dt, "OilModel");
                actualNum = ColumnChange(dt, "ActualNum");
                bTNo = ColumnChange(dt, "BTNo");
                bJBTNO = ColumnChange(dt, "BJBTNO");
                okMan = ColumnChange(dt, "OkMan");
                field = ColumnChange(dt, "Field");
                makeMan = ColumnChange(dt, "MakeMan");
                skiller = ColumnChange(dt, "Skiller");
                if (string.IsNullOrEmpty(handlerTime))
                {
                    handlerTime = DateTime.Now.Date.ToString("yyyy-MM-dd");
                }
                else
                {
                    handlerTime = Convert.ToDateTime(ColumnChange(dt, "HandlerTime")).ToString("yyyy-MM-dd");
                }
                fClass2 = ColumnChange(dt, "FClass2");
                machine2 = ColumnChange(dt, "Machine2");
                subModel = ColumnChange(dt, "SubModel");
                subBTNum = ColumnChange(dt, "SubBTNum");
                interfuse = ColumnChange(dt, "Interfuse");
                residual = ColumnChange(dt, "Residual");
                remarks = ColumnChange(dt, "Remarks");
            }


        }

        /// <summary>
        /// 获取datatable对应列的数据
        /// </summary>
        /// <param name="columnname"></param>
        /// <returns></returns>
        private string ColumnChange(DataTable dt, string columnname)
        {
            return dt.Rows[0][columnname].ToString();
        }

        /// <summary>
        /// 根据id获取对应台账明细
        /// </summary>
        /// <returns></returns>
        private DataTable GetLedgerById()
        {
            DataTable dt = new DataTable();
            dt = leBll.GetLedgerById(id);
            return dt;
        }
    }
}